package com.nuaa.yupicturebackend.controller;

import com.nuaa.client.HunyuanClient;
import com.nuaa.entity.HunyuanRequest;
import com.nuaa.entity.HunyuanResponse;
import com.nuaa.entity.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;

/**
 * @author: ortonzhu
 * @data 2025年03月24日 14:37
 * @Description
 */
@RestController
@RequestMapping("/ai")
public class AIController {

	@Autowired
	private HunyuanClient client;

	@PostMapping("/chat")
	public String chat(String userInput, String userId) {
		List<HunyuanRequest.Message> messages = Collections.singletonList(
				new HunyuanRequest.Message("user", userInput)
		);
		HunyuanResponse response = client.executeChat(messages, userId);
		return ResponseUtil.extractContent(response);
	}
}
